#!/bin/bash

tmux has-session -t kube
if [ $? != 0 ]; then
    tmux new-session -s kube -n editor -e 'VIM_SERVER_NAME=kube' -d -c '/opt/sources/kubernetes'
    tmux send-keys -t kube 'vim --servername kube README.md' C-m
    tmux new-window -t kube -n ranger 'ranger /home/luyanfei/Documents/geektime/CloudNative /opt/sources/cncamp101 /opt/sources/kubernetes /snap/go/current/src'
    # tmux new-window -d -n ssh -t kube
    # tmux send-keys -t kube:3 'ssh hw1' C-m
    tmux new-window -n work -t kube -c /opt/sources/k8scamp/httpserver
    tmux send-keys -t kube "alias vt='vim --servername kube --remote-tab'" C-m
    # tmux send-keys -t kube "alias k=kubectl" C-m
    # tmux send-keys -t kube "alias ki='kubectl -n ingress-nginx'" C-m
    # tmux send-keys -t kube "alias ks='kubectl -n kube-system'" C-m
    # tmux send-keys -t kube "alias kt='kubectl -n tekton-pipelines'" C-m
    tmux send-keys -t kube "clear" C-m
    # tmux split-window -t kube:notes -v -l6 -c /opt/sources/k8scamp/httpserver
    # tmux select-pane -U -t kube:notes
    tmux select-window -t kube:2
fi

if [ -z "$TMUX" ]; then
    tmux -u attach-session -t kube
else
    tmux -u switch-client -t kube
fi
